/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MenuMainForm.java
 *
 * Created on 05 Nov 11, 12:08:39
 */
package SistemPenyewaanKamar;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Yosefina
 */
public class MenuMainForm extends javax.swing.JFrame {

    /** Creates new form MenuMainForm */
    public MenuMainForm() {
        try {
            addWindowListener(new WindowAdapter() {

                @Override
                public void windowOpened(WindowEvent e) {
                    setExtendedState(MAXIMIZED_BOTH);
                }
            });
            initComponents();
            MainController.setFrame(this);
            MainController.showDateAndClock(tanggalJamLabel);
            MainController.showKaryawan(namaUserLabel, idLabel, jabatanLAbel);
            MainController.aturMenu(jabatanLAbel, checkinMenuItem,
                    checkOutMenuItem, hallRentingMenuItem, makeReportMenu);
        } catch (Exception ex) {
            Logger.getLogger(MenuMainForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        copyrightLabel = new javax.swing.JLabel();
        idLabel = new javax.swing.JLabel();
        namaUserLabel = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jabatanLAbel = new javax.swing.JLabel();
        namaHotelLabel = new javax.swing.JLabel();
        tanggalJamLabel = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        logoutButton = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        menuFile = new javax.swing.JMenu();
        checkinMenuItem = new javax.swing.JMenuItem();
        checkOutMenuItem = new javax.swing.JMenuItem();
        makeReportMenu = new javax.swing.JMenu();
        dailyMenuItem = new javax.swing.JMenuItem();
        monthlyMenuItem = new javax.swing.JMenuItem();
        hallRentingMenuItem = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        exitMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Menu Main Form");

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        copyrightLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        copyrightLabel.setText("The contents of this application are copyright © 2011 MIAA Company       ");

        idLabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        idLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        namaUserLabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jLabel2.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        jLabel2.setText("Selamat Datang");

        jabatanLAbel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        namaHotelLabel.setFont(new java.awt.Font("Nyala", 0, 48)); // NOI18N
        namaHotelLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        namaHotelLabel.setText("MIAA HOTEL MANAGEMENT");

        tanggalJamLabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tanggalJamLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/SistemPenyewaanKamar/headerHotel.jpg"))); // NOI18N

        logoutButton.setForeground(new java.awt.Color(255, 0, 0));
        logoutButton.setText("LOGOUT");
        logoutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 970, Short.MAX_VALUE)
            .addComponent(namaHotelLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 970, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(821, Short.MAX_VALUE)
                .addComponent(logoutButton, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addComponent(tanggalJamLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 970, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(37, 37, 37)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(namaUserLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(idLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jabatanLAbel, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 108, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(678, Short.MAX_VALUE))
            .addComponent(copyrightLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 970, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(namaHotelLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(8, 8, 8)
                .addComponent(logoutButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(tanggalJamLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addGap(24, 24, 24)
                .addComponent(namaUserLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(idLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jabatanLAbel, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
                .addComponent(copyrightLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        menuFile.setText("Menu");

        checkinMenuItem.setText("Checkin");
        checkinMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkinMenuItemActionPerformed(evt);
            }
        });
        menuFile.add(checkinMenuItem);

        checkOutMenuItem.setText("Checkout");
        checkOutMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkOutMenuItemActionPerformed(evt);
            }
        });
        menuFile.add(checkOutMenuItem);

        makeReportMenu.setText("Make a Report");

        dailyMenuItem.setText("Make a Daily Report");
        dailyMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dailyMenuItemActionPerformed(evt);
            }
        });
        makeReportMenu.add(dailyMenuItem);

        monthlyMenuItem.setText("Make a Monthly Report");
        monthlyMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                monthlyMenuItemActionPerformed(evt);
            }
        });
        makeReportMenu.add(monthlyMenuItem);

        menuFile.add(makeReportMenu);

        hallRentingMenuItem.setText("Hall Renting");
        hallRentingMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hallRentingMenuItemActionPerformed(evt);
            }
        });
        menuFile.add(hallRentingMenuItem);
        menuFile.add(jSeparator1);

        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        menuFile.add(exitMenuItem);

        jMenuBar1.add(menuFile);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents

    private void checkinMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkinMenuItemActionPerformed
        MainController.openCheckinDialog(this);
    }//GEN-LAST:event_checkinMenuItemActionPerformed

    private void checkOutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkOutMenuItemActionPerformed
        MainController.openCheckOutDialog(this);
    }//GEN-LAST:event_checkOutMenuItemActionPerformed

    private void hallRentingMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hallRentingMenuItemActionPerformed
        try {
            MainController.openHallRentingDialog(this);
        } catch (SQLException ex) {
//            Logger.getLogger(MenuMainForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_hallRentingMenuItemActionPerformed

    private void dailyMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dailyMenuItemActionPerformed
        MainController.openDailyReportDialog(this);
    }//GEN-LAST:event_dailyMenuItemActionPerformed

    private void monthlyMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_monthlyMenuItemActionPerformed
        MainController.openMonthlyDialog(this);
    }//GEN-LAST:event_monthlyMenuItemActionPerformed

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        try {
            MainController.exit();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
        }
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButtonActionPerformed
        try {
            MainController.logout();
        } catch (Exception ex) {
        }
    }//GEN-LAST:event_logoutButtonActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem checkOutMenuItem;
    private javax.swing.JMenuItem checkinMenuItem;
    private javax.swing.JLabel copyrightLabel;
    private javax.swing.JMenuItem dailyMenuItem;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenuItem hallRentingMenuItem;
    private javax.swing.JLabel idLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JLabel jabatanLAbel;
    private javax.swing.JButton logoutButton;
    private javax.swing.JMenu makeReportMenu;
    private javax.swing.JMenu menuFile;
    private javax.swing.JMenuItem monthlyMenuItem;
    private javax.swing.JLabel namaHotelLabel;
    private javax.swing.JLabel namaUserLabel;
    private javax.swing.JLabel tanggalJamLabel;
    // End of variables declaration//GEN-END:variables
}
